package com.zhaojk.audio.mapper;

import com.zhaojk.audio.entity.Word;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WordMapper {
    @Select("SELECT * FROM words WHERE id = #{id}")
    Word findById(Long id);

    @Insert("INSERT INTO words(word, freq, level) VALUES(#{word}, #{freq}, #{level})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Word word);

    @Update("UPDATE words SET word=#{word}, freq=#{freq}, level=#{level} WHERE id=#{id}")
    void update(Word word);

    @Delete("DELETE FROM words WHERE id=#{id}")
    void delete(Long id);

    @Select("SELECT * FROM words")
    List<Word> findAll();
}
